package com.ctrl.riveradministrator.mvp.view.weight;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.ctrl.riveradministrator.R;
import com.ctrl.riveradministrator.RaApplication;
import com.ctrl.riveradministrator.common.Constants;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class RiverInfoDialog extends Dialog implements View.OnClickListener, SelectTypeRadioGroup.OnClickListener {

    private Context context;
    private String id;
    private List<String> data = new ArrayList<>();
    private TextView dataDTv;
    private TextView hhxxTv, gcxxTv, szyTv, swrTv, syanTv, sscTv, shjTv, qwqzTv, hjcgTv;
    private SelectTypeRadioGroup hhxxSelect, gcxxSelect, szySelect, swrSelect, syaxSelect,
            sscSelect, shjSelect, qwqzSelect, hjcgSelect;
    private ListView list;
    private ArrayAdapter arrayAdapter;
    private String type = "其他";
    private String[] hehuxinxi = new String[]{"河道信息", "水库信息", "湿地信息", "公示牌信息"};
    private String[] gongchengxinxi = new String[]{"闸坝", "泵站", "堤防", "涉河项目", "在建工程"};
    private String[] shuiziyuan = new String[]{"取水口", "水功能区", "取水户"};
    private String[] shuiwuran = new String[]{"入河排污口", "工业污染源", "其他污染源"};
    private String[] shuiyuanxian = new String[]{"保护区", "保留区", "控制区", "开发利用区"};
    private String[] shuishengchan = new String[]{"湿地(公园)", "水利风景区", "生态河道"};
    private String[] shuihuanjing = new String[]{"黑臭水体", "饮用水源地"};
    private String[] qingweiqingzhang = new String[]{"合法事项", "问题事项"};
    private String[] huajiechengguo = new String[]{"管理范围", "保护范围", "界桩", "公告牌", "已确权"};
    private Drawable[] hehuxinxid = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.tb1),
            RaApplication.resources.getDrawable(R.drawable.sk),
            RaApplication.resources.getDrawable(R.drawable.sd),
            RaApplication.resources.getDrawable(R.drawable.gsp)
    };
    private Drawable[] gongchengxinxid = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.zhaba),
            RaApplication.resources.getDrawable(R.drawable.bengz),
            RaApplication.resources.getDrawable(R.drawable.dfang),
            RaApplication.resources.getDrawable(R.drawable.thxm),
            RaApplication.resources.getDrawable(R.drawable.zjgc)
    };
    private Drawable[] shuiziyuand = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh)
    };
    private Drawable[] shuiwurand = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh)
    };
    private Drawable[] shuiyuanxiand = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh),
            RaApplication.resources.getDrawable(R.drawable.qsh)
    };
    private Drawable[] shuishengchand = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh)
    };
    private Drawable[] shuihuanjingd = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq)
    };
    private Drawable[] qingweiqingzhangd = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq)
    };
    private Drawable[] huajiechengguod = new Drawable[]{
            RaApplication.resources.getDrawable(R.drawable.qsk),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh),
            RaApplication.resources.getDrawable(R.drawable.sgnq),
            RaApplication.resources.getDrawable(R.drawable.qsh)
    };

    public RiverInfoDialog(Context context) {
        super(context);
        this.context = context;
    }

    public void showText(String s) {
        View view = LayoutInflater.from(context).inflate(R.layout.text, null);
        TextView textView = view.findViewById(R.id.text);
        textView.setText(s);
        setContentView(view);
        show();
    }

    public void showDialog(String id) {
        this.id = id;
        View view = LayoutInflater.from(context).inflate(R.layout.add_account_dialog, null);
        list = view.findViewById(R.id.list);
        hhxxTv = view.findViewById(R.id.t1);
        gcxxTv = view.findViewById(R.id.t2);
        szyTv = view.findViewById(R.id.t3);
        swrTv = view.findViewById(R.id.t4);
        syanTv = view.findViewById(R.id.t5);
        sscTv = view.findViewById(R.id.t6);
        shjTv = view.findViewById(R.id.t7);
        qwqzTv = view.findViewById(R.id.t8);
        hjcgTv = view.findViewById(R.id.t9);
        dataDTv = view.findViewById(R.id.data_tv);
        hhxxSelect = view.findViewById(R.id.hehuxinxi);
        gcxxSelect = view.findViewById(R.id.gongchengxinxi);
        szySelect = view.findViewById(R.id.shuiziyuan);
        swrSelect = view.findViewById(R.id.shuiwuran);
        syaxSelect = view.findViewById(R.id.shuiyuanxian);
        sscSelect = view.findViewById(R.id.shuishengchan);
        shjSelect = view.findViewById(R.id.shuihuanjing);
        qwqzSelect = view.findViewById(R.id.qingweiqingzhang);
        hjcgSelect = view.findViewById(R.id.huajiechengguo);
        hhxxSelect.setListener(this);
        gcxxSelect.setListener(this);
        szySelect.setListener(this);
        swrSelect.setListener(this);
        sscSelect.setListener(this);
        szySelect.setListener(this);
        shjSelect.setListener(this);
        qwqzSelect.setListener(this);
        hjcgSelect.setListener(this);
        hhxxTv.setOnClickListener(this);
        gcxxTv.setOnClickListener(this);
        szyTv.setOnClickListener(this);
        swrTv.setOnClickListener(this);
        syanTv.setOnClickListener(this);
        sscTv.setOnClickListener(this);
        shjTv.setOnClickListener(this);
        qwqzTv.setOnClickListener(this);
        hjcgTv.setOnClickListener(this);
        for (int i = 0; i < hehuxinxi.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(hehuxinxi[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, hehuxinxid[i], null, null);
            hhxxSelect.addView(radioButton);
        }
        for (int i = 0; i < gongchengxinxi.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(gongchengxinxi[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, gongchengxinxid[i], null, null);
            gcxxSelect.addView(radioButton);
        }
        for (int i = 0; i < shuiziyuan.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(shuiziyuan[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, shuiziyuand[i], null, null);
            szySelect.addView(radioButton);
        }
        for (int i = 0; i < shuiwuran.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(shuiwuran[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, shuiwurand[i], null, null);
            swrSelect.addView(radioButton);
        }
        for (int i = 0; i < shuiyuanxian.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(shuiyuanxian[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, shuiyuanxiand[i], null, null);
            syaxSelect.addView(radioButton);
        }
        for (int i = 0; i < shuishengchan.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(shuishengchan[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, shuishengchand[i], null, null);
            sscSelect.addView(radioButton);
        }
        for (int i = 0; i < shuihuanjing.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(shuihuanjing[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, shuihuanjingd[i], null, null);
            shjSelect.addView(radioButton);
        }
        for (int i = 0; i < qingweiqingzhang.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(qingweiqingzhang[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, qingweiqingzhangd[i], null, null);
            qwqzSelect.addView(radioButton);
        }
        for (int i = 0; i < huajiechengguo.length; i++) {
            RadioButton radioButton = (RadioButton) this.getLayoutInflater().inflate(R.layout.radio_button, null);
            radioButton.setText(huajiechengguo[i]);
            radioButton.setCompoundDrawablesWithIntrinsicBounds(null, huajiechengguod[i], null, null);
            hjcgSelect.addView(radioButton);
        }

        arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, data);
        list.setAdapter(arrayAdapter);
        setContentView(view);
        show();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.t1:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.VISIBLE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t2:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.VISIBLE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t3:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.VISIBLE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t4:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.VISIBLE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t5:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.VISIBLE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t6:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.VISIBLE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t7:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.VISIBLE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t8:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.VISIBLE);
                hjcgSelect.setVisibility(View.GONE);
                break;
            case R.id.t9:
                hhxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                gcxxTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                szyTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                swrTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                syanTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                sscTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                shjTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                qwqzTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_gray_round_cornor));
                hjcgTv.setBackground(RaApplication.resources.getDrawable(R.drawable.shape_blue_btn_round_cornor));
                hhxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                gcxxTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                szyTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                swrTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                syanTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                sscTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                shjTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                qwqzTv.setTextColor(RaApplication.resources.getColor(R.color.color66));
                hjcgTv.setTextColor(RaApplication.resources.getColor(R.color.white));
                hhxxSelect.setVisibility(View.GONE);
                gcxxSelect.setVisibility(View.GONE);
                szySelect.setVisibility(View.GONE);
                swrSelect.setVisibility(View.GONE);
                syaxSelect.setVisibility(View.GONE);
                sscSelect.setVisibility(View.GONE);
                shjSelect.setVisibility(View.GONE);
                qwqzSelect.setVisibility(View.GONE);
                hjcgSelect.setVisibility(View.VISIBLE);
                break;
        }
    }

    @Override
    public void select(String type) {
        this.type = type;
        data.clear();
        switch (type) {
            case "河道信息":
                postProjectData("api/selectReachForId", id,"reachName");
                break;
            case "水库信息":
                postProjectData("api/selectReservoirForId", id,"reservoirName");
                break;
            case "湿地信息":
                postProjectData("api/selectWetlandInformationForId", id,"name");
                break;
            case "公示牌信息":
                postProjectData("api/selectPsignForId", id,"psignName");
                break;
            case "闸坝":
                postProjectData("api/selectGateForId", id,"gateName");
                break;
            case "泵站":
                postProjectData("api/selectPumpstationForId", id,"pumpstationName");
                break;
            case "堤防":
                postProjectData("api/selectDamForId", id,"damName");
                break;
            case "涉河项目":
                postProjectData("api/selectCourseForId", id,"rivercourseName");
                break;
            case "在建工程":
                postProjectData("api/selectBridgeForId", id,"bridgeName");
                break;
        }

    }

    private void postProjectData(String url, String id,String name) {
        OkHttpClient client = new OkHttpClient();//创建OkHttpClient对象。
        FormBody.Builder formBody = new FormBody.Builder();//创建表单请求体
        formBody.add("id", id);//传递键值对参数
        Log.d("res", "id:" + id);
        Request request = new Request.Builder()//创建Request 对象。
                .url(Constants.BASE_URL + url)
                .post(formBody.build())//传递请求体
                .build();
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String s = response.body().string();
                Log.d("res", "res:" + s);
                try {
                    if (response.isSuccessful()) {
                        JSONObject jsonObject = new JSONObject(s);
                        String JSON = jsonObject.get("dataList").toString();
                        JSONArray jsonArray = new JSONArray(JSON);
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject JSONdata = new JSONObject(jsonArray.getJSONObject(i).toString());
                            data.add(JSONdata.getString(name));
                        }
                        if (data.size()>0){
                            dataDTv.post(() -> dataDTv.setVisibility(View.GONE));
                            list.post(() -> {
                                list.setVisibility(View.VISIBLE);
                                arrayAdapter.notifyDataSetChanged();
                            });
                        }else{
                            dataDTv.post(() -> dataDTv.setVisibility(View.VISIBLE));
                            list.post(() -> list.setVisibility(View.GONE));
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
